import * as echarts from 'echarts'

/**
 * 基础饼状图
 * @param el
 * @param params
 * @param name
 * @author 赵京涛
 */
export const usePieEchartsHandler = (el, params, name) => {
  const myChart = echarts.init(el)
  const option = {
    legend: {
      top: 'bottom'
    },
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b} : {c} ({d}%)'
    },
    toolbox: {
      show: true,
      feature: {
        mark: { show: true },
        dataView: { show: true, readOnly: false },
        restore: { show: true },
        saveAsImage: { show: true }
      }
    },
    series: [
      {
        name,
        type: 'pie',
        // radius: [50, 250],
        center: ['50%', '50%'],
        roseType: 'area',
        itemStyle: {
          borderRadius: 8
        },
        data: params.seriesData
      }
    ]
  }
  option && myChart.setOption(option)
}
